﻿<Window x:Class="TestApplicaton.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:clipping="clr-namespace:BorderClippingExtension;assembly=BorderClippingExtension"
        Title="MainWindow" Height="350" Width="525" Background="Yellow">
    <Window.Resources>
        <Path x:Key="Star"
              Width="250"
              Stretch="Fill"
              Fill="Red"
              Data="M50,0 L61.80275,38.197539 L100,38.1966 L69.097251,61.803039 L80.901699,99.999998 L50,76.39204 L19.098301,99.999998 L30.902749,61.803039 L1.1879072E-07,38.1966 L38.19725,38.197539 z"
              x:Shared="False"
              />
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Button x:Name="B1" Width="100" Height="20" Margin="-250,0,0,0" Style="{DynamicResource ButtonStyle1}"/>
        <Button x:Name="B2" Width="100" Height="20" Margin="200,0,0,0"/>
        <Ellipse x:Name="B3" Width="50" Height="50" Margin="200,200,0,0" Fill="Green"/>
        <Grid clipping:ClippingExtension.ClippingDistance="{DynamicResource Dist}">
            <Border Width="200" HorizontalAlignment="Stretch" BorderBrush="Red" CornerRadius="20" BorderThickness="2" Background="LightYellow"/>
            <clipping:ClippingExtension.ClippingElements>
                <clipping:ClippingElementContainer Element="{Binding ElementName=B1}"/>
                <clipping:ClippingElementContainer Element="{Binding ElementName=B2}"/>
                <clipping:ClippingElementContainer Element="{Binding ElementName=B3}"/>
            </clipping:ClippingExtension.ClippingElements>
        </Grid>
        <Grid Grid.Row="1">
            <Grid clipping:ClippingExtension.ClippingDistance="20">
                <clipping:ClippingExtension.ClippingElements>
                    <clipping:ClippingElementContainer Element="{Binding ElementName=StarControl}"/>
                </clipping:ClippingExtension.ClippingElements>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="40"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Border CornerRadius="20" BorderBrush="Black" BorderThickness="5" Background="LightBlue"/>
                <Border CornerRadius="20" BorderBrush="Black" BorderThickness="5" Background="LightBlue" Grid.Column="2"/>
            </Grid>
            <ContentControl x:Name="StarControl" Content="{StaticResource Star}" VerticalAlignment="Stretch"/>
        </Grid>
    </Grid>
</Window>
